/* $OpenBSD: tlslegacytest.c,v 1.7 2022/10/02 16:39:39 jsing Exp $ */
/*
 * Copyright (c) 2015, 2016, 2017, 2020 Joel Sing <jsing@openbsd.org>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <openssl/ssl.h>

#include <err.h>
#include <stdio.h>
#include <string.h>

/* openssl.org:443 */
static uint8_t tls12_server_response[] = {
	0x16, 0x03, 0x03, 0x00, 0x3d, 0x02, 0x00, 0x00,
	0x39, 0x03, 0x03, 0x62, 0x0c, 0x8a, 0x7e, 0x29,
	0x60, 0xcb, 0x08, 0xd1, 0xb4, 0x95, 0x68, 0x76,
	0xea, 0x4e, 0x0c, 0x94, 0xf2, 0x42, 0x3d, 0xd1,
	0x7a, 0xc2, 0xfe, 0x6c, 0xb3, 0xe6, 0x12, 0x8a,
	0x33, 0x02, 0x92, 0x00, 0xc0, 0x30, 0x00, 0x00,
	0x11, 0xff, 0x01, 0x00, 0x01, 0x00, 0x00, 0x0b,
	0x00, 0x04, 0x03, 0x00, 0x01, 0x02, 0x00, 0x23,
	0x00, 0x00,
};

/*
 * outlook.office365.com:587 with starttls - this server response includes
 * multiple handshake messages contained in a single TLS record.
 */
static uint8_t tls12_server_response_with_cert[] = {
	0x16, 0x03, 0x03, 0x0f, 0x2b, 0x02, 0x00, 0x00,
	0x4d, 0x03, 0x03, 0x5f, 0x7c, 0x69, 0x42, 0xe1,
	0x19, 0xf0, 0x22, 0xfb, 0x71, 0x9a, 0xf1, 0x63,
	0x34, 0xbb, 0x61, 0x46, 0xea, 0x5f, 0x0b, 0x5e,
	0xb1, 0x4e, 0x37, 0x96, 0x67, 0xff, 0x83, 0xea,
	0x0e, 0x16, 0x85, 0x20, 0x3a, 0x1b, 0x00, 0x00,
	0x17, 0xe9, 0xac, 0xca, 0x19, 0x61, 0xaf, 0x70,
	0x28, 0x3b, 0x18, 0xaa, 0x6c, 0xa0, 0x0f, 0x78,
	0xd0, 0x83, 0xfc, 0x5d, 0x78, 0xf9, 0x6d, 0xdb,
	0x16, 0x21, 0x15, 0xa2, 0xc0, 0x30, 0x00, 0x00,
	0x05, 0xff, 0x01, 0x00, 0x01, 0x00, 0x0b, 0x00,
	0x0d, 0x47, 0x00, 0x0d, 0x44, 0x00, 0x08, 0xaf,
	0x30, 0x82, 0x08, 0xab, 0x30, 0x82, 0x07, 0x93,
	0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x0c, 0x6d,
	0xea, 0x0b, 0xe1, 0x97, 0x27, 0x60, 0xa1, 0x59,
	0xb1, 0x85, 0x60, 0x30, 0x0d, 0x06, 0x09, 0x2a,
	0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x01, 0x0b,
	0x05, 0x00, 0x30, 0x66, 0x31, 0x0b, 0x30, 0x09,
	0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x42,
	0x45, 0x31, 0x19, 0x30, 0x17, 0x06, 0x03, 0x55,
	0x04, 0x0a, 0x13, 0x10, 0x47, 0x6c, 0x6f, 0x62,
	0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x6e,
	0x76, 0x2d, 0x73, 0x61, 0x31, 0x3c, 0x30, 0x3a,
	0x06, 0x03, 0x55, 0x04, 0x03, 0x13, 0x33, 0x47,
	0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69, 0x67,
	0x6e, 0x20, 0x4f, 0x72, 0x67, 0x61, 0x6e, 0x69,
	0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x56,
	0x61, 0x6c, 0x69, 0x64, 0x61, 0x74, 0x69, 0x6f,
	0x6e, 0x20, 0x43, 0x41, 0x20, 0x2d, 0x20, 0x53,
	0x48, 0x41, 0x32, 0x35, 0x36, 0x20, 0x2d, 0x20,
	0x47, 0x33, 0x30, 0x1e, 0x17, 0x0d, 0x32, 0x30,
	0x30, 0x38, 0x31, 0x33, 0x32, 0x33, 0x31, 0x38,
	0x34, 0x39, 0x5a, 0x17, 0x0d, 0x32, 0x32, 0x30,
	0x38, 0x31, 0x34, 0x32, 0x33, 0x31, 0x38, 0x34,
	0x39, 0x5a, 0x30, 0x6a, 0x31, 0x0b, 0x30, 0x09,
	0x06, 0x03, 0x55, 0x04, 0x06, 0x13, 0x02, 0x55,
	0x53, 0x31, 0x13, 0x30, 0x11, 0x06, 0x03, 0x55,
	0x04, 0x08, 0x13, 0x0a, 0x57, 0x61, 0x73, 0x68,
	0x69, 0x6e, 0x67, 0x74, 0x6f, 0x6e, 0x31, 0x10,
	0x30, 0x0e, 0x06, 0x03, 0x55, 0x04, 0x07, 0x13,
	0x07, 0x52, 0x65, 0x64, 0x6d, 0x6f, 0x6e, 0x64,
	0x31, 0x1e, 0x30, 0x1c, 0x06, 0x03, 0x55, 0x04,
	0x0a, 0x13, 0x15, 0x4d, 0x69, 0x63, 0x72, 0x6f,
	0x73, 0x6f, 0x66, 0x74, 0x20, 0x43, 0x6f, 0x72,
	0x70, 0x6f, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
	0x31, 0x14, 0x30, 0x12, 0x06, 0x03, 0x55, 0x04,
	0x03, 0x13, 0x0b, 0x6f, 0x75, 0x74, 0x6c, 0x6f,
	0x6f, 0x6b, 0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dc, 0x1f, 0x6d, 0x90, 0xd0, 0xce, 0x14, 0x1e,
	0x6c, 0xdc, 0x7b, 0x06, 0xe4, 0x7b, 0xa9, 0x81,
	0x40, 0xed, 0xde, 0x18, 0xb7, 0xdf, 0x53, 0x61,
	0xbc, 0x18, 0x83, 0x11, 0xc7, 0xb4, 0x1b, 0x99,
	0xef, 0x14, 0xe4, 0x63, 0x39, 0xe3, 0x5c, 0x2f,
	0xe7, 0x89, 0x58, 0x5b, 0xda, 0x03, 0x3a, 0x39,
	0x96, 0x8a, 0xca, 0x4f, 0xd8, 0xe3, 0x6c, 0x7f,
	0x6e, 0xd3, 0xe7, 0x30, 0x34, 0x9c, 0xdb, 0x8b,
	0xe8, 0x6a, 0xa6, 0x08, 0x77, 0x1d, 0x63, 0xd6,
	0x57, 0x9d, 0xcd, 0xa7, 0x47, 0x05, 0x39, 0x96,
	0x7b, 0xfd, 0x9a, 0x09, 0x99, 0xef, 0x49, 0xb1,
	0x89, 0x02, 0xbe, 0x4f, 0xb8, 0xef, 0xa0, 0x04,
	0x29, 0x74, 0xfb, 0x9a, 0x7e, 0x9d, 0xa8, 0x10,
	0xfb, 0x7e, 0xb0, 0x6c, 0x60, 0x4f, 0x57, 0x02,
	0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x05, 0x53,
	0x30, 0x82, 0x05, 0x4f, 0x30, 0x0e, 0x06, 0x03,
	0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04, 0x04,
	0x03, 0x02, 0x05, 0xa0, 0x30, 0x81, 0x9e, 0x06,
	0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x01,
	0x01, 0x04, 0x81, 0x91, 0x30, 0x81, 0x8e, 0x30,
	0x4b, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
	0x07, 0x30, 0x02, 0x86, 0x3f, 0x68, 0x74, 0x74,
	0x70, 0x3a, 0x2f, 0x2f, 0x73, 0x65, 0x63, 0x75,
	0x72, 0x65, 0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61,
	0x6c, 0x73, 0x69, 0x67, 0x6e, 0x2e, 0x63, 0x6f,
	0x6d, 0x2f, 0x63, 0x61, 0x63, 0x65, 0x72, 0x74,
	0x2f, 0x67, 0x73, 0x6f, 0x72, 0x67, 0x61, 0x6e,
	0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x76,
	0x61, 0x6c, 0x73, 0x68, 0x61, 0x32, 0x67, 0x33,
	0x2e, 0x63, 0x72, 0x74, 0x30, 0x3f, 0x06, 0x08,
	0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x30, 0x01,
	0x86, 0x33, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
	0x2f, 0x6f, 0x63, 0x73, 0x70, 0x32, 0x2e, 0x67,
	0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73, 0x69, 0x67,
	0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x73,
	0x6f, 0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61,
	0x74, 0x69, 0x6f, 0x6e, 0x76, 0x61, 0x6c, 0x73,
	0x68, 0x61, 0x32, 0x67, 0x33, 0x30, 0x56, 0x06,
	0x03, 0x55, 0x1d, 0x20, 0x04, 0x4f, 0x30, 0x4d,
	0x30, 0x41, 0x06, 0x09, 0x2b, 0x06, 0x01, 0x04,
	0x01, 0xa0, 0x32, 0x01, 0x14, 0x30, 0x34, 0x30,
	0x32, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
	0x07, 0x02, 0x01, 0x16, 0x26, 0x68, 0x74, 0x74,
	0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77,
	0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x73,
	0x69, 0x67, 0x6e, 0x2e, 0x63, 0x6f, 0x6d, 0x2f,
	0x72, 0x65, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x6f,
	0x72, 0x79, 0x2f, 0x30, 0x08, 0x06, 0x06, 0x67,
	0x81, 0x0c, 0x01, 0x02, 0x02, 0x30, 0x09, 0x06,
	0x03, 0x55, 0x1d, 0x13, 0x04, 0x02, 0x30, 0x00,
	0x30, 0x46, 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04,
	0x3f, 0x30, 0x3d, 0x30, 0x3b, 0xa0, 0x39, 0xa0,
	0x37, 0x86, 0x35, 0x68, 0x74, 0x74, 0x70, 0x3a,
	0x2f, 0x2f, 0x63, 0x72, 0x6c, 0x2e, 0x67, 0x6c,
	0x6f, 0x62, 0x61, 0x6c, 0x73, 0x69, 0x67, 0x6e,
	0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x73, 0x6f,
	0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74,
	0x69, 0x6f, 0x6e, 0x76, 0x61, 0x6c, 0x73, 0x68,
	0x61, 0x32, 0x67, 0x33, 0x2e, 0x63, 0x72, 0x6c,
	0x30, 0x82, 0x02, 0x10, 0x06, 0x03, 0x55, 0x1d,
	0x11, 0x04, 0x82, 0x02, 0x07, 0x30, 0x82, 0x02,
	0x03, 0x82, 0x0b, 0x6f, 0x75, 0x74, 0x6c, 0x6f,
	0x6f, 0x6b, 0x2e, 0x63, 0x6f, 0x6d, 0x82, 0x16,
	0x2a, 0x2e, 0x63, 0x6c, 0x6f, 0x2e, 0x66, 0x6f,
	0x6f, 0x74, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x64,
	0x6e, 0x73, 0x2e, 0x63, 0x6f, 0x6d, 0x82, 0x0d,
	0x2a, 0x2e, 0x68, 0x6f, 0x74, 0x6d, 0x61, 0x69,
	0x6c, 0x2e, 0x63, 0x6f, 0x6d, 0x82, 0x16, 0x2a,
	0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61,
	0x6c, 0x2e, 0x6f, 0x75, 0x74, 0x6c, 0x6f, 0x6f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e, 0x74,
	0x2e, 0x6f, 0x75, 0x74, 0x6c, 0x6f, 0x6f, 0x6b,
	0x2e, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x70,
	0x70, 0x65, 0x2e, 0x6e, 0x65, 0x74, 0x82, 0x16,
	0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65,
	0x6e, 0x74, 0x73, 0x2e, 0x6f, 0x66, 0x66, 0x69,
	0x63, 0x65, 0x2e, 0x6e, 0x65, 0x74, 0x82, 0x1a,
	0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65,
	0x6e, 0x74, 0x73, 0x2d, 0x73, 0x64, 0x66, 0x2e,
	0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x2e, 0x6e,
	0x65, 0x74, 0x82, 0x1d, 0x63, 0x63, 0x73, 0x2e,
	0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x2e, 0x6d, 0x69,
	0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x6f,
	0x6e, 0x6c, 0x69, 0x6e, 0x65, 0x2e, 0x63, 0x6f,
	0x6d, 0x82, 0x21, 0x63, 0x63, 0x73, 0x2d, 0x73,
	0x64, 0x66, 0x2e, 0x6c, 0x6f, 0x67, 0x69, 0x6e,
	0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f,
	0x66, 0x74, 0x6f, 0x6e, 0x6c, 0x69, 0x6e, 0x65,
	0x2e, 0x63, 0x6f, 0x6d, 0x82, 0x0b, 0x68, 0x6f,
	0x74, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x63, 0x6f,
	0x6d, 0x82, 0x16, 0x6d, 0x61, 0x69, 0x6c, 0x2e,
	0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x73,
	0x2e, 0x6c, 0x69, 0x76, 0x65, 0x2e, 0x63, 0x6f,
	0x6d, 0x82, 0x0d, 0x6f, 0x66, 0x66, 0x69, 0x63,
	0x65, 0x33, 0x36, 0x35, 0x2e, 0x63, 0x6f, 0x6d,
	0x82, 0x12, 0x6f, 0x75, 0x74, 0x6c, 0x6f, 0x6f,
	0x6b, 0x2e, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65,
	0x2e, 0x63, 0x6f, 0x6d, 0x82, 0x14, 0x73, 0x75,
	0x62, 0x73, 0x74, 0x72, 0x61, 0x74, 0x65, 0x2e,
	0x6f, 0x66, 0x66, 0x69, 0x63, 0x65, 0x2e, 0x63,
	0x6f, 0x6d, 0x82, 0x18, 0x73, 0x75, 0x62, 0x73,
	0x74, 0x72, 0x61, 0x74, 0x65, 0x2d, 0x73, 0x64,
	0x66, 0x2e, 0x6f, 0x66, 0x66, 0x69, 0x63, 0x65,
	0x2e, 0x63, 0x6f, 0x6d, 0x30, 0x1d, 0x06, 0x03,
	0x55, 0x1d, 0x25, 0x04, 0x16, 0x30, 0x14, 0x06,
	0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07, 0x03,
	0x01, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05,
	0x07, 0x03, 0x02, 0x30, 0x1f, 0x06, 0x03, 0x55,
	0x1d, 0x23, 0x04, 0x18, 0x30, 0x16, 0x80, 0x14,
	0x68, 0x86, 0xb8, 0x7d, 0x7a, 0xd9, 0x6d, 0x49,
	0x6b, 0x87, 0x2f, 0x18, 0x8b, 0x15, 0x34, 0x6c,
	0xd7, 0xb4, 0x7a, 0x0e, 0x30, 0x1d, 0x06, 0x03,
	0x55, 0x1d, 0x0e, 0x04, 0x16, 0x04, 0x14, 0x8a,
	0x7c, 0x73, 0x44, 0x70, 0xa8, 0x4d, 0x83, 0x25,
	0x6f, 0xa6, 0x53, 0xda, 0x42, 0x52, 0x96, 0xc9,
	0x15, 0x71, 0x21, 0x30, 0x82, 0x01, 0x7c, 0x06,
	0x0a, 0x2b, 0x06, 0x01, 0x04, 0x01, 0xd6, 0x79,
	0x02, 0x04, 0x02, 0x04, 0x82, 0x01, 0x6c, 0x04,
	0x82, 0x01, 0x68, 0x01, 0x66, 0x00, 0x76, 0x00,
	0x22, 0x45, 0x45, 0x07, 0x59, 0x55, 0x24, 0x56,
	0x96, 0x3f, 0xa1, 0x2f, 0xf1, 0xf7, 0x6d, 0x86,
	0xe0, 0x23, 0x26, 0x63, 0xad, 0xc0, 0x4b, 0x7f,
	0x5d, 0xc6, 0x83, 0x5c, 0x6e, 0xe2, 0x0f, 0x02,
	0x00, 0x00, 0x01, 0x73, 0xea, 0x1e, 0x7d, 0x2f,
	0x00, 0x00, 0x04, 0x03, 0x00, 0x47, 0x30, 0x45,
	0x02, 0x21, 0x00, 0xf4, 0x50, 0x8f, 0xe7, 0x38,
	0xc9, 0x7a, 0xd1, 0xf7, 0xf7, 0x69, 0xc5, 0x05,
	0xea, 0x8e, 0x03, 0x80, 0x2c, 0x87, 0x06, 0x03,
	0xb6, 0x9b, 0xe6, 0xa5, 0x83, 0x2f, 0xb9, 0xaf,
	0x7b, 0xb4, 0xac, 0x02, 0x20, 0x51, 0xa6, 0x8f,
	0xe8, 0xe5, 0x6c, 0xa7, 0xff, 0x16, 0x01, 0x7e,
	0x15, 0x42, 0x11, 0x31, 0xdc, 0xdc, 0xc7, 0x37,
	0x7c, 0x64, 0x2c, 0xac, 0xdd, 0x42, 0xbb, 0x3c,
	0x79, 0x31, 0x74, 0xcc, 0x9d, 0x00, 0x75, 0x00,
	0x29, 0x79, 0xbe, 0xf0, 0x9e, 0x39, 0x39, 0x21,
	0xf0, 0x56, 0x73, 0x9f, 0x63, 0xa5, 0x77, 0xe5,
	0xbe, 0x57, 0x7d, 0x9c, 0x60, 0x0a, 0xf8, 0xf9,
	0x4d, 0x5d, 0x26, 0x5c, 0x25, 0x5d, 0xc7, 0x84,
	0x00, 0x00, 0x01, 0x73, 0xea, 0x1e, 0x7a, 0xa7,
	0x00, 0x00, 0x04, 0x03, 0x00, 0x46, 0x30, 0x44,
	0x02, 0x20, 0x03, 0xf1, 0x19, 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 0x1b, 0x1f, 0x21, 0x45, 0x92, 0xc5, 0x9a,
	0x47, 0x05, 0x0f, 0xb8, 0x1c, 0x78, 0x6e, 0xb9,
	0x6b, 0xa3, 0xa9, 0x8d, 0xb1, 0x59, 0xff, 0xf4,
	0xe6, 0x71, 0x77, 0x38, 0x12, 0xfe, 0x41, 0x8f,
	0x04, 0x92, 0x08, 0x3f, 0x32, 0x2a, 0x92, 0x5e,
	0x0a, 0x7b, 0x7e, 0x04, 0xee, 0x24, 0x10, 0x39,
	0xf3, 0xac, 0x5e, 0x04, 0x93, 0x91, 0xa2, 0x8f,
	0x90, 0x04, 0x33, 0x5c, 0x5c, 0x94, 0xb3, 0x80,
	0x2b, 0x43, 0xbf, 0xe3, 0x74, 0x64, 0x20, 0xf4,
	0x00, 0xb2, 0x6c, 0x7b, 0xa8, 0x77, 0xfb, 0x74,
	0x35, 0xce, 0xdd, 0xb6, 0x5f, 0x83, 0x18, 0xc4,
	0xe7, 0x31, 0x1a, 0x8d, 0x30, 0x0d, 0xc4, 0x00,
	0x04, 0x8f, 0x30, 0x82, 0x04, 0x8b, 0x30, 0x82,
	0x03, 0x73, 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02,
	0x0e, 0x47, 0x07, 0xb1, 0x01, 0x9a, 0x0c, 0x57,
	0xad, 0x39, 0xb3, 0xe1, 0x7d, 0xa9, 0xf9, 0x30,
	0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7,
	0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x57,
	0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55, 0x04,
	0x06, 0x13, 0x02, 0x42, 0x45, 0x31, 0x19, 0x30,
	0x17, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13, 0x10,
	0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53, 0x69,
	0x67, 0x6e, 0x20, 0x6e, 0x76, 0x2d, 0x73, 0x61,
	0x31, 0x10, 0x30, 0x0e, 0x06, 0x03, 0x55, 0x04,
	0x0b, 0x13, 0x07, 0x52, 0x6f, 0x6f, 0x74, 0x20,
	0x43, 0x41, 0x31, 0x1b, 0x30, 0x19, 0x06, 0x03,
	0x55, 0x04, 0x03, 0x13, 0x12, 0x47, 0x6c, 0x6f,
	0x62, 0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x20,
	0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41, 0x30,
	0x1e, 0x17, 0x0d, 0x31, 0x35, 0x30, 0x39, 0x30,
	0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a,
	0x17, 0x0d, 0x32, 0x35, 0x30, 0x39, 0x30, 0x34,
	0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x5a, 0x30,
	0x66, 0x31, 0x0b, 0x30, 0x09, 0x06, 0x03, 0x55,
	0x04, 0x06, 0x13, 0x02, 0x42, 0x45, 0x31, 0x19,
	0x30, 0x17, 0x06, 0x03, 0x55, 0x04, 0x0a, 0x13,
	0x10, 0x47, 0x6c, 0x6f, 0x62, 0x61, 0x6c, 0x53,
	0x69, 0x67, 0x6e, 0x20, 0x6e, 0x76, 0x2d, 0x73,
	0x61, 0x31, 0x3c, 0x30, 0x3a, 0x06, 0x03, 0x55,
	0x04, 0x03, 0x13, 0x33, 0x47, 0x6c, 0x6f, 0x62,
	0x61, 0x6c, 0x53, 0x69, 0x67, 0x6e, 0x20, 0x4f,
	0x72, 0x67, 0x61, 0x6e, 0x69, 0x7a, 0x61, 0x74,
	0x69, 0x6f, 0x6e, 0x20, 0x56, 0x61, 0x6c, 0x69,
	0x64, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x43,
	0x41, 0x20, 0x2d, 0x20, 0x53, 0x48, 0x41, 0x32,
	0x35, 0x36, 0x20, 0x2d, 0x20, 0x47, 0x33, 0x30,
	0x82, 0x01, 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a,
	0x86, 0x48,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,
	0xd1, 0x6e, 0x70, 0x4a, 0xf0, 0xd8, 0x63, 0x60,
	0x6a, 0x72, 0x55, 0xd7, 0xf1, 0x99, 0x38, 0x86,
	0x44, 0x67, 0x18, 0xe0, 0x71, 0x8e, 0xc1, 0x40,
	0x6d, 0x85, 0xda, 0x4b, 0xdd, 0x31, 0x73, 0xbc,
	0x32, 0xcc, 0x6f, 0x8e, 0x7b, 0xb9, 0x8d, 0x4b,
	0x80, 0xda, 0xb9, 0xc7, 0xc6, 0x24, 0x83, 0x5e,
	0x32, 0xfb, 0x87, 0xe9, 0x8b, 0x61, 0x67, 0xa2,
	0x99, 0x76, 0xdb, 0xa5, 0xaa, 0xb4, 0xe8, 0x6c,
	0x41, 0x9f, 0x5f, 0x2a, 0xb3, 0xd5, 0x7d, 0xd7,
	0x92, 0xc8, 0x27, 0x4b, 0xec, 0x1f, 0xda, 0x05,
	0x6d, 0x88, 0x73, 0x8f, 0x06, 0xb2, 0x38, 0x3d,
	0x03, 0xa2, 0xe1, 0x87, 0x86, 0x3c, 0xc6, 0xa1,
	0x02, 0x03, 0x01, 0x00, 0x01, 0xa3, 0x82, 0x01,
	0x44, 0x30, 0x82, 0x01, 0x40, 0x30, 0x0e, 0x06,
	0x03, 0x55, 0x1d, 0x0f, 0x01, 0x01, 0xff, 0x04,
	0x04, 0x03, 0x02, 0x01, 0x06, 0x30, 0x1d, 0x06,
	0x03, 0x55, 0x1d, 0x25, 0x04, 0x16, 0x30, 0x14,
	0x06, 0x08, 0x2b, 0x06, 0x01, 0x05, 0x05, 0x07,
	0x03, 0x01, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
	0x05, 0x07, 0x03, 0x02, 0x30, 0x12, 0x06, 0x03,
	0x55, 0x1d, 0x13, 0x01, 0x01, 0xff, 0x04, 0x08,
	0x30, 0x06, 0x01, 0x01, 0xff, 0x02, 0x01, 0x00,
	0x30, 0x1d, 0x06, 0x03, 0x55, 0x1d, 0x0e, 0x04,
	0x16, 0x04, 0x14, 0x68, 0x86, 0xb8, 0x7d, 0x7a,
	0xd9, 0x6d, 0x49, 0x6b, 0x87, 0x2f, 0x18, 0x8b,
	0x15, 0x34, 0x6c, 0xd7, 0xb4, 0x7a, 0x0e, 0x30,
	0x1f, 0x06, 0x03, 0x55, 0x1d, 0x23, 0x04, 0x18,
	0x30, 0x16, 0x80, 0x14, 0x60, 0x7b, 0x66, 0x1a,
	0x45, 0x0d, 0x97, 0xca, 0x89, 0x50, 0x2f, 0x7d,
	0x04, 0xcd, 0x34, 0xa8, 0xff, 0xfc, 0xfd, 0x4b,
	0x30, 0x3d, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
	0x05, 0x07, 0x01, 0x01, 0x04, 0x31, 0x30, 0x2f,
	0x30, 0x2d, 0x06, 0x08, 0x2b, 0x06, 0x01, 0x05,
	0x05, 0x07, 0x30, 0x01, 0x86, 0x21, 0x68, 0x74,
	0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6f, 0x63, 0x73,
	0x70, 0x2e, 0x67, 0x6c, 0x6f, 0x62, 0x61, 0x6c,
	0x73, 0x69, 0x67, 0x6e, 0x2e, 0x63, 0x6f, 0x6d,
	0x2f, 0x72, 0x6f, 0x6f, 0x74, 0x72, 0x31, 0x30,
	0x33, 0x06, 0x03, 0x55, 0x1d, 0x1f, 0x04, 0x2c,
	0x30, 0x2a, 0x30, 0x28, 0xa0, 0x26, 0xa0, 0x24,
	0x86, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
	0x2f, 0x63, 0x72, 0x6c, 0x2e, 0x67, 0x6c, 0x6f,
	0x62, 0x61, 0x6c, 0x73, 0x69, 0x67, 0x6e, 0x2e,
	0x63, 0x6f, 0x6d, 0x2f, 0x72, 0x6f, 0x6f, 0x74,
	0x2e, 0x63, 0x72, 0x6c, 0x30, 0x47, 0x06, 0x03,
	0x55, 0x1d, 0x20, 0x04, 0x40, 0x30, 0x3e, 0x30,
	0x3c, 0x06, 0x04, 0x55, 0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 0x00, 0x00, 0x00,
};

struct tlslegacy_client_test {
	const unsigned char *desc;
	unsigned char *server_response;
	const size_t server_response_len;
	const SSL_METHOD *(*ssl_method)(void);
	int want_state;
};

static struct tlslegacy_client_test tlslegacy_client_tests[] = {
	{
		.desc = "TLSv1.2 legacy fallback",
		.server_response = tls12_server_response,
		.server_response_len = sizeof(tls12_server_response),
		.ssl_method = TLS_client_method,
		.want_state = SSL3_ST_CR_CERT_A,
	},
	{
		.desc = "TLSv1.2 legacy fallback with server cert",
		.server_response = tls12_server_response_with_cert,
		.server_response_len = sizeof(tls12_server_response_with_cert),
		.ssl_method = TLS_client_method,
		.want_state = SSL3_ST_CR_KEY_EXCH_B,
	},
};

#define N_TLSLEGACY_CLIENT_TESTS \
    (sizeof(tlslegacy_client_tests) / sizeof(*tlslegacy_client_tests))

static int
tlslegacy_client_test(int testno, struct tlslegacy_client_test *tct)
{
	BIO *rbio = NULL, *wbio = NULL;
	SSL_CTX *ssl_ctx = NULL;
	SSL *ssl = NULL;
	int ret = 1;

	fprintf(stderr, "Test %d - %s\n", testno, tct->desc);

	if ((rbio = BIO_new_mem_buf(tct->server_response,
	    tct->server_response_len)) == NULL) {
		fprintf(stderr, "Failed to setup rbio\n");
		goto failure;
	}
	if ((wbio = BIO_new(BIO_s_mem())) == NULL) {
		fprintf(stderr, "Failed to setup wbio\n");
		goto failure;
	}

	if ((ssl_ctx = SSL_CTX_new(tct->ssl_method())) == NULL) {
		fprintf(stderr, "SSL_CTX_new() returned NULL\n");
		goto failure;
	}

	if ((ssl = SSL_new(ssl_ctx)) == NULL) {
		fprintf(stderr, "SSL_new() returned NULL\n");
		goto failure;
	}

	BIO_up_ref(rbio);
	BIO_up_ref(wbio);
	SSL_set_bio(ssl, rbio, wbio);

	if (SSL_connect(ssl) == 1) {
		fprintf(stderr, "SSL_connect() succeeded\n");
		goto failure;
	}

	if (SSL_state(ssl) != tct->want_state) {
		fprintf(stderr, "FAIL: Got SSL state %x, want %x",
		    SSL_state(ssl), tct->want_state);
		goto failure;
	}

	ret = 0;

 failure:
	SSL_CTX_free(ssl_ctx);
	SSL_free(ssl);

	BIO_free(rbio);
	BIO_free(wbio);

	return (ret);
}

int
main(int argc, char **argv)
{
	int failed = 0;
	size_t i;

	for (i = 0; i < N_TLSLEGACY_CLIENT_TESTS; i++)
		failed |= tlslegacy_client_test(i, &tlslegacy_client_tests[i]);

	return (failed);
}
